/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcontact.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vcontact.model.VContact;
import com.vportal.portlet.vcontact.model.VContactModel;
import com.vportal.portlet.vcontact.model.VContactSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VContact service. Represents a row in the &quot;VContact&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcontact.model.VContactModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VContactImpl}.
 * </p>
 *
 * @author LongLH
 * @see VContactImpl
 * @see com.vportal.portlet.vcontact.model.VContact
 * @see com.vportal.portlet.vcontact.model.VContactModel
 * @generated
 */
@JSON(strict = true)
public class VContactModelImpl extends BaseModelImpl<VContact>
	implements VContactModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a v contact model instance should use the {@link com.vportal.portlet.vcontact.model.VContact} interface instead.
	 */
	public static final String TABLE_NAME = "VContact";
	public static final Object[][] TABLE_COLUMNS = {
			{ "id_", Types.BIGINT },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "createdDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "guestName", Types.VARCHAR },
			{ "email", Types.VARCHAR },
			{ "title", Types.VARCHAR },
			{ "address", Types.VARCHAR },
			{ "phone", Types.VARCHAR },
			{ "fax", Types.VARCHAR },
			{ "content", Types.VARCHAR },
			{ "hasAttach", Types.BOOLEAN },
			{ "status", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table VContact (id_ LONG not null primary key,groupId LONG,companyId LONG,createdDate DATE null,modifiedDate DATE null,guestName VARCHAR(75) null,email VARCHAR(75) null,title VARCHAR(150) null,address VARCHAR(250) null,phone VARCHAR(75) null,fax VARCHAR(75) null,content VARCHAR(550) null,hasAttach BOOLEAN,status INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table VContact";
	public static final String ORDER_BY_JPQL = " ORDER BY vContact.createdDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY VContact.createdDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcontact.model.VContact"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcontact.model.VContact"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcontact.model.VContact"),
			true);
	public static long GROUPID_COLUMN_BITMASK = 1L;
	public static long STATUS_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VContact toModel(VContactSoap soapModel) {
		VContact model = new VContactImpl();

		model.setId(soapModel.getId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setGuestName(soapModel.getGuestName());
		model.setEmail(soapModel.getEmail());
		model.setTitle(soapModel.getTitle());
		model.setAddress(soapModel.getAddress());
		model.setPhone(soapModel.getPhone());
		model.setFax(soapModel.getFax());
		model.setContent(soapModel.getContent());
		model.setHasAttach(soapModel.getHasAttach());
		model.setStatus(soapModel.getStatus());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VContact> toModels(VContactSoap[] soapModels) {
		List<VContact> models = new ArrayList<VContact>(soapModels.length);

		for (VContactSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcontact.model.VContact"));

	public VContactModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return VContact.class;
	}

	public String getModelClassName() {
		return VContact.class.getName();
	}

	@JSON
	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_id = id;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_columnBitmask = -1L;

		_createdDate = createdDate;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public String getGuestName() {
		if (_guestName == null) {
			return StringPool.BLANK;
		}
		else {
			return _guestName;
		}
	}

	public void setGuestName(String guestName) {
		_guestName = guestName;
	}

	@JSON
	public String getEmail() {
		if (_email == null) {
			return StringPool.BLANK;
		}
		else {
			return _email;
		}
	}

	public void setEmail(String email) {
		_email = email;
	}

	@JSON
	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	@JSON
	public String getAddress() {
		if (_address == null) {
			return StringPool.BLANK;
		}
		else {
			return _address;
		}
	}

	public void setAddress(String address) {
		_address = address;
	}

	@JSON
	public String getPhone() {
		if (_phone == null) {
			return StringPool.BLANK;
		}
		else {
			return _phone;
		}
	}

	public void setPhone(String phone) {
		_phone = phone;
	}

	@JSON
	public String getFax() {
		if (_fax == null) {
			return StringPool.BLANK;
		}
		else {
			return _fax;
		}
	}

	public void setFax(String fax) {
		_fax = fax;
	}

	@JSON
	public String getContent() {
		if (_content == null) {
			return StringPool.BLANK;
		}
		else {
			return _content;
		}
	}

	public void setContent(String content) {
		_content = content;
	}

	@JSON
	public boolean getHasAttach() {
		return _hasAttach;
	}

	public boolean isHasAttach() {
		return _hasAttach;
	}

	public void setHasAttach(boolean hasAttach) {
		_hasAttach = hasAttach;
	}

	@JSON
	public int getStatus() {
		return _status;
	}

	public void setStatus(int status) {
		_columnBitmask |= STATUS_COLUMN_BITMASK;

		if (!_setOriginalStatus) {
			_setOriginalStatus = true;

			_originalStatus = _status;
		}

		_status = status;
	}

	public int getOriginalStatus() {
		return _originalStatus;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VContact toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VContact)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
					VContact.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		VContactImpl vContactImpl = new VContactImpl();

		vContactImpl.setId(getId());
		vContactImpl.setGroupId(getGroupId());
		vContactImpl.setCompanyId(getCompanyId());
		vContactImpl.setCreatedDate(getCreatedDate());
		vContactImpl.setModifiedDate(getModifiedDate());
		vContactImpl.setGuestName(getGuestName());
		vContactImpl.setEmail(getEmail());
		vContactImpl.setTitle(getTitle());
		vContactImpl.setAddress(getAddress());
		vContactImpl.setPhone(getPhone());
		vContactImpl.setFax(getFax());
		vContactImpl.setContent(getContent());
		vContactImpl.setHasAttach(getHasAttach());
		vContactImpl.setStatus(getStatus());

		vContactImpl.resetOriginalValues();

		return vContactImpl;
	}

	public int compareTo(VContact vContact) {
		int value = 0;

		value = DateUtil.compareTo(getCreatedDate(), vContact.getCreatedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VContact vContact = null;

		try {
			vContact = (VContact)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = vContact.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		VContactModelImpl vContactModelImpl = this;

		vContactModelImpl._originalGroupId = vContactModelImpl._groupId;

		vContactModelImpl._setOriginalGroupId = false;

		vContactModelImpl._originalStatus = vContactModelImpl._status;

		vContactModelImpl._setOriginalStatus = false;

		vContactModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VContact> toCacheModel() {
		VContactCacheModel vContactCacheModel = new VContactCacheModel();

		vContactCacheModel.id = getId();

		vContactCacheModel.groupId = getGroupId();

		vContactCacheModel.companyId = getCompanyId();

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			vContactCacheModel.createdDate = createdDate.getTime();
		}
		else {
			vContactCacheModel.createdDate = Long.MIN_VALUE;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			vContactCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			vContactCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		vContactCacheModel.guestName = getGuestName();

		String guestName = vContactCacheModel.guestName;

		if ((guestName != null) && (guestName.length() == 0)) {
			vContactCacheModel.guestName = null;
		}

		vContactCacheModel.email = getEmail();

		String email = vContactCacheModel.email;

		if ((email != null) && (email.length() == 0)) {
			vContactCacheModel.email = null;
		}

		vContactCacheModel.title = getTitle();

		String title = vContactCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			vContactCacheModel.title = null;
		}

		vContactCacheModel.address = getAddress();

		String address = vContactCacheModel.address;

		if ((address != null) && (address.length() == 0)) {
			vContactCacheModel.address = null;
		}

		vContactCacheModel.phone = getPhone();

		String phone = vContactCacheModel.phone;

		if ((phone != null) && (phone.length() == 0)) {
			vContactCacheModel.phone = null;
		}

		vContactCacheModel.fax = getFax();

		String fax = vContactCacheModel.fax;

		if ((fax != null) && (fax.length() == 0)) {
			vContactCacheModel.fax = null;
		}

		vContactCacheModel.content = getContent();

		String content = vContactCacheModel.content;

		if ((content != null) && (content.length() == 0)) {
			vContactCacheModel.content = null;
		}

		vContactCacheModel.hasAttach = getHasAttach();

		vContactCacheModel.status = getStatus();

		return vContactCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(29);

		sb.append("{id=");
		sb.append(getId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", guestName=");
		sb.append(getGuestName());
		sb.append(", email=");
		sb.append(getEmail());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", address=");
		sb.append(getAddress());
		sb.append(", phone=");
		sb.append(getPhone());
		sb.append(", fax=");
		sb.append(getFax());
		sb.append(", content=");
		sb.append(getContent());
		sb.append(", hasAttach=");
		sb.append(getHasAttach());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(46);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcontact.model.VContact");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>guestName</column-name><column-value><![CDATA[");
		sb.append(getGuestName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>email</column-name><column-value><![CDATA[");
		sb.append(getEmail());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>address</column-name><column-value><![CDATA[");
		sb.append(getAddress());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>phone</column-name><column-value><![CDATA[");
		sb.append(getPhone());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>fax</column-name><column-value><![CDATA[");
		sb.append(getFax());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>content</column-name><column-value><![CDATA[");
		sb.append(getContent());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hasAttach</column-name><column-value><![CDATA[");
		sb.append(getHasAttach());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VContact.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VContact.class
		};
	private long _id;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private Date _createdDate;
	private Date _modifiedDate;
	private String _guestName;
	private String _email;
	private String _title;
	private String _address;
	private String _phone;
	private String _fax;
	private String _content;
	private boolean _hasAttach;
	private int _status;
	private int _originalStatus;
	private boolean _setOriginalStatus;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private VContact _escapedModelProxy;
}